package com.fzh.bookstore.biz.goods.controller;


import com.fzh.bookstore.biz.banner.dto.BannerListRequest;
import com.fzh.bookstore.biz.goods.dto.GoodsInfoRequest;
import com.fzh.bookstore.biz.goods.dto.GoodsListRequest;
import com.fzh.bookstore.biz.goods.dto.RecommendGoodsRequest;
import com.fzh.bookstore.biz.goods.service.GoodsService;
import com.fzh.bookstore.biz.goods.service.impl.GoodsServiceImpl;
import com.fzh.bookstore.dto.SuperResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fang
 * @since 2021-02-25
 */
@RestController
@RequestMapping("/goods")
@Api(value = "商品模块",tags = {"商品模块"})
public class GoodsController {

    @Autowired
    private GoodsServiceImpl goodsService;


    @PostMapping("/recommend")
    @ApiOperation(value = "首页推荐的书（APP）" ,notes = "")
    public SuperResponse list(@Valid @RequestBody RecommendGoodsRequest request ){
        return  goodsService.getRecommendGoods(request);
    }



    @PostMapping("/goodsInfo")
    @ApiOperation(value = "书本详情（APP）" ,notes = "")
    public SuperResponse goodsInfo(@Valid @RequestBody GoodsInfoRequest request ){
        return  goodsService.findGoods(request);
    }

    @PostMapping("/findGoodsByCid")
    @ApiOperation(value = "根据商品分类获取商品（APP）" ,notes = "")
    public SuperResponse findGoodsByCid(@Valid @RequestBody GoodsListRequest request ){
        return  goodsService.findGoodsByCid(request);
    }
}

